package org.example.cake.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.example.cake.common.Rep;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.cake.entity.User;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Mapper
public interface UserMapper {
    int deleteByPrimaryKey(Integer userid);

    int insert(User record);

    int insertSelective(User record);

    User selectByPrimaryKey(Integer userid);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    List<User> SelectUserHou(@Param("username") String username,
                             @Param("userphone") String userphone,
                             @Param("status") Integer status);

    int toggleStatus(@Param("ids") List<Long> ids);

    //通过openid查询用户是否存在
    @Select("select * from user where openid= #{openid}")
    User selectuseropenid(@Param("openid") String openid);

    /**
     * 查询所有用户列表
     * @author luojiangjin
     * @return 用户列表
     */
    List<User> selectAllUsers();

    /**
     * 根据用户ID查询用户
     * @author luojiangjin
     * @param userId 用户ID
     * @return 用户实体
     */
    User selectUserById(@Param("userId") Integer userId);

    /**
     * 修改用户信息
     * @param user 用户对象
     * @return 受影响的行数
     */
    int updateUser(User user);

    /**
     * 根据用户id查询用户信息
     * @param userid 用户id
     * @return 用户对象
     */
    User selectUserByUserId(@Param("userid") Integer userid);

    /**
     * 根据openid查询用户
     * @param openid openid
     * @return  用户实体
     */
    @Select("select * from user where openid=#{openid}")
    public User findByOpenid(@Param("openid") String openid);
}